package com.cqc.service.impl;

import com.cqc.service.ProductService;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.web.context.request.async.DeferredResult;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;

/**
 * @author cui
 * @date 2023/3/4 18:11
 **/

@Service
public class ProductServiceImpl implements ProductService {


    @Async
    @Override
    public void addOrder1(String orderId, DeferredResult<String> deferredResult) {
        System.out.println(Thread.currentThread().getName());
        //模拟耗时操作
        try {
            TimeUnit.MINUTES.sleep(1L);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        deferredResult.setResult("操作完成");
        System.out.println("操作完成");
    }


}
